1. Field of the Invention
The invention relates to the art of document processing. More specifically, the invention relates to the art of copying a first image or portion of a first image and pasting the copy into a second image or portion of a second image where the source of the first image is a TWAIN data source. For example, the invention finds use where the first image data source is a TWAIN compliant scanner or image database. While the invention is described in relation to a TWAIN compliant scanner, the invention may be used in association with any TWAIN complaint data source.
2. Description of Related Art
TWAIN is the name of a protocol or communications standard that has been developed in order to help image processing devices communicate with each other. For example, TWAIN is used to help computers communicate with scanners and digital cameras. Additionally, TWAIN is used in some xerographic environments. Complete details of the TWAIN standard are available from The TWAIN Working Group, 13090 Hwy. 9, Suite 3, Boulder Creek, Calif. 95006.
Understanding of aspects of the invention may be aided by a review of some aspects of the TWAIN standard.
TWAIN defines a standard software protocol and application-programming interface (API) for communication between software applications and image acquisition devices (the source of the data). Three main elements in TWAIN are: 1) an application, such as, for example, a document scan and make ready tool, a desktop publishing application, a word processing application and document or image processors; 2) source software, which is software that controls an image acquisition device and is written by the image acquisition device developer to comply with TWAIN specifications; and 3) source manager software, which is software that manages interactions between the application and the Source.
FIG. 1 shows exemplary components of TWAIN compliant image processing systems 110. An application 114 sends commands to a source 118 by sending commands, in the form of TWAIN operation triplets, to the Source Manager 122. The Source Manager sends the triplets on to the source software (xe2x80x9cSourcexe2x80x9d) 126.
An operation is an action that the application 114 or Source Manager 122 invokes. A triplet is a command that uniquely, and without ambiguity, specifies a particular action. No operation is specified by more than a single triplet. Three parameters make up a triplet. The three parameters are Data Group, Data Argument Type, and Message ID. Each parameter conveys specific information.
Operations are divided into large categories by the Data Group identifier (Data Group (DG_xxxx)). There are only three data groups currently defined in TWAIN. A Control Data Group (DG_CONTROL) includes operations that involve control of a TWAIN session. An example where DG_CONTROL is used as the Data Group identifier is the operation to open the Source Manager. An IMAGE Data Group (DG_IMAGE) includes operations that work with image data. An example where DG_IMAGE is used as a Data Group is an operation that requests the transfer of image data. An AUDIO Data Group (DG_AUDIO) includes operations that work with audio data from, for example, some digital cameras. An example where DG_AUDIO is used as a Data Group is an operation that requests the transfer of audio data.
One of TWAIN""s benefits is it allows applications to easily interact with a variety of acquisition devices. Devices can provide image or audio data. For instance, some devices have automatic document feeders. Furthermore, some devices are not limited to one image but can transfer multiple images. Some devices support color images. Some devices offer a variety of halftone patterns. Some devices support a range of resolutions while others may offer different choices. For example, many devices operating in a xerographic environment have automatic document feeders. Many xerographic devices can transfer multiple images between a scanner and an application. Some devices operating in xerographic environments operate in color and offer a variety of halftone patterns. Some devices allow the recording of audio data associated with an image.
It is important for an application to be aware of a Source""s capabilities. For example, the capabilities of a source may influence the way an application chooses to scale or resize an image. Therefore TWAIN allows an application to perform capability negotiation with a source. The application generally follows this process: 1. Determine if the selected Source supports a particular capability. 2. Inquire about the Current Value for this capability. Also, inquire about the capability""s Default Value and a set of available values that are supported by the Source for that capability. 3. Request that the Source set the Current Value to the application""s desired value. The Current Value will be displayed as the current selection in the Source""s user interface (xe2x80x9cUIxe2x80x9d). 4. Limit, if needed, the Source""s available values to a subset of what would normally be offered. For instance, if the application wants only black and white data, it can restrict the Source to transmit only black and white data. 5. Verify that the new values have been accepted by the Source.
There are three modes that can be used to transfer data from the Source to the application. The three modes are native, disk file, and buffered memory.
Every Source must support Native transfer mode. It is the default mode and is the easiest for an application to implement. However, it is restrictive (i.e. limited to Device-Independent Bitmap (DIB) or PICT formats and limited by available memory). The format of the data is platform-specific. For example Windows applications use DIB. The Source allocates a single block of memory and writes the image data into the block. The Source passes a pointer to the application indicating the memory location of the block. The application is responsible for freeing the memory after the transfer.
A Source is not required to support Disk File transfer mode but it is recommended. In Disk File transfer mode, the application creates the file to be used in the transfer and ensures that it is accessible by the Source for reading and writing. A capability exists that allows the application to determine which file formats the Source supports. The application can then specify the file format and file name to be used in the transfer. The Disk File mode is ideal when transferring large images that might encounter memory limitations with Native mode. Disk File mode is simpler to implement than the Buffered Memory mode. However, Disk File mode is a bit slower than Buffered Memory mode and the application must be able to manage the file after creation.
Every Source must support Buffered Memory transfer mode. The transfer occurs through memory using one or more buffers. Memory for the buffers is allocated and deallocated by the application. The data is transferred as an unformatted bitmap. The application must use information available during the transfer to learn about each individual buffer and be able to correctly interpret the bitmap.
If using the Native or Disk File transfer modes, the transfer is completed in one action. With the Buffered Memory mode, the application may need to loop repeatedly to obtain more than one buffer of data. Buffered Memory transfer offers the greatest flexibility, both in data capture and control. However, it is the least simple to implement.
Referring to FIG. 2, it is logical that a process for communicating between image processing devices, such as the TWAIN protocol, must occur in a particular sequence. For example, the application cannot successfully request the transfer of data from a Source before the Source Manager is loaded and prepared to communicate the request. To ensure the sequence is executed correctly, the TWAIN protocol defines seven states 210 that exist in TWAIN sessions. A session is, for example, a period while an application is connected to a particular source via the Source Manager. The period while the application is connected to the Source Manager is another unique session. At a given point in a session, the TWAIN elements of Source Manager and Source each occupy a particular state. Transitions to a new state are caused by operations requested by the application or Source. Transitions can be in the forward or backward direction. Most transitions are single-state transitions. For example, an operation moves the Source Manager from State 1 to State 2 and generally not from State 1 to State 3. However, there are situations where a two-state transition may occur. The situations are discussed in Chapter 3 of the TWAIN specification.
When viewing the state-based protocol, it is helpful to remember that States 1, 2, and 3 are occupied only by the Source Manager. The Source Manager never occupies a state greater than State 3. States 4, 5, 6, and 7 are occupied exclusively by Sources. A Source never has a state less than 4 if it is open. If the Source is closed, the Source has no state. If an application uses multiple Sources, each connection is a separate session and each open Source xe2x80x9cresidesxe2x80x9d in its own state without regard for what state other Sources are in.
From any given state, only certain operations are possible. Additionally, any given operation can only be performed from a certain state. For example, the only time an acquire or scan operation can be performed is during a transition from TWAIN state 4 220 to state 5 224. State 5 includes the displaying of a source user interface (xe2x80x9cUIxe2x80x9d). These facts set up a conundrum. In order to copy or cut, and past a portion of a scanned image into, for example a document or image in an application, an application must tell the scanner which part of the image to scan. However, a user cannot make a source image selection, thereby informing the application which part of the image is of interest, until the source is displaying the image. When the source is in state 5 224 and displaying the image, the application can no longer send a command to scan the selected portion of the image. Therefore, cutting or copying and pasting a portion of an image from a TWAIN data source has involved a process of trial and error. While the source is in state 5, with a UI showing, a user makes an image portion selection and requests a scan. The scan is made, image portion data is transferred to the application, and the Source returns to state 4 or is closed completely. The user then manipulates the image portion in the application in an attempt to make the image portion fit in a target location. If the attempt is unsuccessful, the user must reopen the Source UI and make a new selection. Additionally, the user may request that a new scan be made with a different scaling factor and/or with a different scanning resolution. These steps are repeated until the user is satisfied with an image portion selection and with an image portion scaling and alignment in the target area. This process can be frustrating and time consuming.
Therefore, a method for copying and pasting from a TWAIN data source that provides for automatic scanning to fit, thereby reducing or eliminating numerous scanning iterations in a document or image preparation process is desirable.
To those ends, a method operative to accomplish copy and paste, and scan to fit, using a TWAIN data source has been developed. The method comprises the steps of selecting a target portion of a destination image that is displayed in an application, selecting a portion of a source image that is displayed in a source user interface, passing coordinate information, corresponding to the selected portion of the source image, to the application, determining at least one resizing parameter based on differences between the target portion of the destination and the selected portion of the source image, scanning the selected portion of the source image in a manner that is based on the resizing parameters to generate a properly scaled copy of the selected portion of the source image, and pasting the properly scaled copy in at the target portion of the destination image.
An exemplary embodiment of the method is operative to copy and paste a portion of a TWAIN compliant data source into an image displayed by a TWAIN compliant application. The method includes selecting a preview mode resolution setting, determining initial selection box settings, opening a TWAIN compliant data source, thereby placing the data source in TWAIN state 4, enabling the data Source with SHOWUI=TRUE, thereby displaying a Source user interface, and passing the selected preview mode resolution setting and the selection box settings to the data source, thereby causing an image to be pre-scanned and displayed along with a selection box as described by the initial selection box settings, and placing the data source in TWAIN state 5, adjusting the selection box settings if need be, in order to select a desired portion of the image for scanning and copying, scanning the selected portion of the image, thereby transitioning to TWAIN state 6, transferring the scanned portion to the application, thereby passing the adjusted selection box settings to the application, returning the source back through TWAIN states 6, 5, and 4, determining resizing parameters based on the adjusted selection box settings and dimensions of a target area in the image in the application, enabling the data source with SHOWUI=FALSE, thereby preventing the display of the Source user interface, and passing resizing parameters and the adjusted selection box settings to the data source, thereby causing the image to be scanned, creating an appropriately sized copy of the selected portion of the image, transferring the appropriately sized copy of the selected portion of the image to the application, and placing the copy of the selected portion of the image in the target area.
An image processing system operative to communicate with a TWAIN image source, and copy and paste, and scan to fit, a selected portion of a source image, into a selected target area, in a destination image includes a TWAIN image source, a source manager, and an application. The application is operative to communicate with the image source, through services of the source manager, to receive a properly sized copy of the selected portion of the source image, and to automatically paste the properly sized copy of the selected portion of the source image into the selected target area of the destination image. In this way the application is used to generate a revised version of the destination image. The image processing system also includes an output device operative to receive the revised image. An example of an output device used when such and application is run in a xerographic environment is a xerographic printer.
One advantage of the present invention is the elimination of frustrating trial and error procedures in copying and pasting operations involving TWAIN sources. For example, scaling and/or resolution parameters are calculated and set automatically. This eliminates guesswork on the part of a user.
Another advantage of the present invention resides in the ability to use the scanner to do resizing. Since the scanner does both resizing and image processing, resizing can be done prior to image processing, thereby preventing scaling artifacts that occur when scaling is done after some image processing methods are applied.
Still other advantages of the present invention will become apparent to those skilled in the art upon a reading and understanding of the detail description below.